package com.cms.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * Utils - 公共
 *
 *
 *
 */
public class CommonUtils {

    /** 不包含 */
    public static List<String> urlExcludes = new ArrayList<String>(){{
        add("/admin");
        add("/ajax");
        add("/category");
        add("/content");
        add("/div");
        add("/guestbook");
        add("/page");
        add("/search");
        add("/tag");
    }};

    /**
     * 获取不包含url带/
     *
     * @return
     */
    public static List<String> getUrlPathExcludes(){
        List<String> urlPathExcludes = new ArrayList<>();
        for(String urlPath : urlExcludes){
            urlPathExcludes.add(urlPath+"/");
        }
        return urlPathExcludes;
    }

    /**
     * url是否包含
     *
     * @param url
     * @return
     */
    public static boolean getUrlPathContains(String url){
        List<String> urlPathExcludes = getUrlPathExcludes();
        for(String urlPathExclude : urlPathExcludes){
            if(url.startsWith(urlPathExclude)){
                return true;
            }
        }
        return false;
    }


}
